<!-- 打赏排行 -->
<template>
    <div >
        <div class='table-page-search-wrapper'>
            <a-form layout='inline'>
               <a-row :gutter='48'>
                    <a-col :md="8" :sm="24">
                        <a-form-item label="打赏方式">
                            <a-select v-model="orderType" placeholder="请选择" allowClear @change="getData">
                                <a-select-option v-for="(item,i) in orderTypeList" :key="i" :value="item.id">{{item.name}}</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :md="8" :sm="24">
                    </a-col>
                    <a-col :md='8' :sm='24'>
                        <a-form-item >
                            <a-button type="primary" @click="getData()">查询</a-button>
                        </a-form-item>
                    </a-col>
                </a-row>
            </a-form>
        </div>  

        <a-table rowKey="id" :loading="isload" :columns="columns" :data-source="dataList" @change="handleTableChange" :pagination="{ pageSize: 10, total: total ,showSizeChanger: true,pageSize: size}" size="small" >
            <div slot="amount" slot-scope="amount">
                <span>{{amount}}</span>
            </div>
            <!-- <div slot="orderType" slot-scope="orderType">
                <div v-for="(item,i) in orderTypeList" :key="item.id">
                    <a-tag v-if="item.id == orderType" :color="colors[i%13]">{{item.name}}</a-tag>
                </div>
            </div>
            <div slot="orderStatus" slot-scope="orderStatus">
                <div v-for="(item,i) in orderStatusList" :key="item.id">
                    <a-tag v-if="item.id == orderStatus" :color="colors[i%13]">{{item.name}}</a-tag>
                </div>
            </div> -->
        </a-table>
    </div>
</template>

<script>
import { queryRewardRanking } from '@/api/protocol';
import { columns } from './table';
export default {
    data () {
        return {
            brandId: this.global.brandId,
            userId: '',
            orderType: undefined,
            orderTypeList: [
                { id: '84', name: '支付宝'},{ id: '85', name: '微信'},
            ],
            orderStatus: 1,
            orderStatusList: [
                { id: '0', name: '未支付',},{ id: '1', name: '支付成功',}
            ],
            dataList: [],
            total: 0,
            isload: false,
            page: 1,
            size: 10,
            colors: ['blue','purple','cyan','green','orange','red','pink','brown','indigo','lime','purple','teal','yellow','amber'],
            columns,
        };
    },
    async created(){
        this.getData()
    },
    methods: {
        getData(){
            let _this = this
            const params = {
                'brandId':_this.brandId,
                'orderType': _this.orderType,
                'orderStatus': _this.orderStatus,
                'size':_this.size,
                'page':_this.page - 1,
            }
            queryRewardRanking(params)
            .then(res=>{
                if(res.success){
                    _this.dataList = res.data.content
                    _this.total = res.data.totalElements
                }else{
                    _this.$notification['error']({
                        message: '提示',
                        description: res.errMessage,
                        duration: 8,
                    })
                }
            })
        },
        // 分页
        handleTableChange(pagination, filters, sorter) {
            console.log(pagination);
            this.page = pagination.current;
            this.size = pagination.pageSize;
            this.getData()
        },
    }
}

</script>
<style scoped>

</style>